<template>
  <div>
    <Breadcrumb :style="{ margin: '15px 0', float: 'left' }">
      <BreadcrumbItem>首页</BreadcrumbItem>
      <BreadcrumbItem>劳务管理</BreadcrumbItem>
      <BreadcrumbItem>人员列表</BreadcrumbItem>
    </Breadcrumb>
    <Content class="layer-content">
      <Form class="search" inline>
        <FormItem>
          <Input style="width: 500px" v-model="keywords" search enter-button placeholder="请输入关键字" @on-search="searchGet" @submit.native.prevent/>
        </FormItem>
        <FormItem>
          <Button @click="reset">重置</Button>
        </FormItem>
      </Form>
      <Table stripe :columns="columnData" :data="dataGrid"></Table>
      <br />
      <HigPager v-model="query" :total="pageTotal" :init="Init"></HigPager>
    </Content>
    <Modal v-model="modalDetail" :footer-hide="true" title="人员简历" width="80%">
      <detail :dataBus="dataItem" :key="keyIndex"></detail>
    </Modal>
  </div>
</template>
<script>
import Detail from "./detail.vue"
export default {
  data() {
    return {
      keyIndex: 0,
      modalDetail: false,
      keywords: null,
      dataItem: {},
      dataGrid: [],
      pageTotal: 0,
      query: {
        equal: {
          orgId: this.$store.getOrg('orgId')
        },
        pageIndex: 1,
        pageSize: 10
      },
      columnData: [
        {
          title: "序号",
          key: "newsId",
          fixed: "left",
          width: 70,
          type: "selection",
        },
        {
          title: "人员姓名",
          width: 120,
          key: "userName"
        },
        {
          title: "性别",
          width: 70,
          key: "userSexText",
        },
        {
          title: "民族",
          key: "userNation",
          width: 120,
        },
        {
          title: "年龄",
          key: "userAge",
          width: 120,
        },
        {
          title: "手机号",
          key: "userMobile",
          width: 180,
        },
        {
          title: "期望岗位",
          key: "bizSourceName",
        },
        {
          title: "申请时间",
          key: "postTime",
          width: 180,
          sortable: true
        },
        {
          title: "操作",
          key: "action",
          width: 120,
          render: (h, params) => {
            return h("Dropdown",{props: {transfer:true,trigger:'click'}},
              [
                h("a",[h("a","下拉菜单"),h("Icon",{props: {type: "ios-arrow-down"}})]),
                h("DropdownMenu",{slot: "list"},
                  [
                    h("DropdownItem",{nativeOn:{click:()=>{this.DetailView(params.row)}}},"详情")
                  ]
                ),
              ]
            )
          }
        }
      ]
    };
  },
  components: {
    Detail
  },
  computed: {
    
  },
  methods: {
    //重置
    reset() {
      delete this.query.sqlLike
      this.keywords = null
      this.Init()
    },
    //搜索
    searchGet() {
      let sqlLike = {
        fields: ['user_name','biz_source_id','user_nation','user_mobile','job_expect','job_notes','job_address'],
        keyword: this.keywords
      }
      this.query.sqlLike = sqlLike
      this.Init()
    },
    //初始化商品
    Init() {
      new this.$rest({
        service: "agrobiz-msg",
        gateway: 'agrobiz',
        url: "/v1.0/corp/recruit/page",
        query: this.query,
        action: (res) => {
          if (res.data.code === 20000) {
            const data = res.data.data
            data.list.forEach(element => {
              element.userSexText = element.userSex === 0 ? '女' : '男'
              element.postTime = this.$date(element.postTime,'yyyy-MM-dd')
            })
            this.dataGrid = data.list
            this.pageTotal = data.count
          } else {
            this.$Notice.warning({
              title: "获取失败",
              desc: `失败原因：${res.data.msg}`,
            });
          }
        },
      }).get();
    },
    DetailView(item) {
      this.dataItem = item
      this.modalDetail = true
    }
  },
  created() {
    this.Init()
  },
};
</script>
